package tom.jiafei;
import java.sql.*;
import java.io.*;
public class Register{
	String userid="sss",uname,passward,tell,address,realName,email;
	public void setUserid(String str){
		userid=str;
	}
	public String getUserid(){
		return userid;
	}
	public void setUname(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            uname=new String(b);}
        catch(Exception e){}
	}
	public String getUname(){
		return uname;
	}
	public void setPassward(String str){
		passward=str;
	}
	public String getPassward(){
		return passward;
	}
	public void setTell(String str){
		tell=str;
	}
	public String getTell(){
		return tell;
	}
	public void setAddress(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            address=new String(b);}
        catch(Exception e){}
	}
	public String getAddress(){
		return address;
	}
	public void setRealName(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            realName=new String(b);}
        catch(Exception e){}
	}
	public String getRealName(){
		return realName;
	}
	public void setEmail(String str){
		email=str;
	}
	public String getEmail(){
		return email;
	}
	public boolean getRegister(){
		boolean  insert=false;
		String insertCondition="insert into user_ values('"+userid+"','"+uname+"','"+passward+"','"+tell+"','"+address+"','"+realName+"','"+email+"')";
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=book_store";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(insertCondition);
		if(m!=0){
			insert=true;			
		}
		con.close();
	}
	catch(SQLException e1){insert=false;}
	return insert;
	}
}